<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('新增医生信息')" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-serviceinfo-add">
            <div class="form-group">
                <label class="col-sm-3 control-label">头像：</label>
                <div class="col-sm-8">
                    <img src="" style="width: 80px;height: 100px;display: none" id="logoImg">
                    <input type="file" class="" id="logo" accept="image/*" onchange="uploadFile()"/>
                    <input type="hidden" name="logo" id="logoVal" value="">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">科室：</label>
                <div class="col-sm-8">
                    <select id="registerId" name="registerId" class="form-control">
                        <option th:each="register : ${registerinfoList}" th:text="${register['name']}" th:value="${register['id']}"></option>
                    </select>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">姓名：</label>
                <div class="col-sm-8">
                    <select id="userId" name="userId" class="form-control">
                        <option th:each="user : ${userList}" th:text="${user['userName']}" th:value="${user['userId']}"></option>
                    </select>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">职称：</label>
                <div class="col-sm-8">
                    <select name="typeInfo" class="form-control m-b" th:with="type=${@dict.getType('doc_professional')}">
                        <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                    </select>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">医生简介：</label>
                <div class="col-sm-8">
                    <textarea name="introduce" class="form-control"></textarea>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">挂号价格：</label>
                <div class="col-sm-8">
                    <input name="price" class="form-control" type="text">
                </div>

            </div>
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <script type="text/javascript">
        var prefix = ctx + "register/serviceinfo"
        $("#form-serviceinfo-add").validate({
            focusCleanup: true
        });

        function uploadFile() {
            var formData = new FormData();
            if ($('#logo')[0].files[0] == null) {
                return false;
            }
            formData.append('file', $('#logo')[0].files[0]);
            var flag = true;
            $.ajax({
                url: ctx + "common/upload",
                type: 'post',
                cache: false,
                data: formData,
                processData: false,
                contentType: false,
                async: false,
                dataType: "json",
                success: function (result) {
                    if (result.code == web_status.SUCCESS) {
                        var data = result.fileName;
                        $("#logoVal").val(data);
                        $("#logoImg").show();
                        $("#logoImg").attr("src", data);
                    } else {
                        $.modal.alertError(result.msg);
                    }
                },
                error: function (error) {
                    $.modal.alertWarning("图片上传失败。");
                }
            });
            return flag;
        }


        function submitHandler() {
            if ($.validate.form()) {
                $.operate.save(prefix + "/add", $('#form-serviceinfo-add').serialize());
            }
        }
    </script>
</body>
</html>
